/**
 * Created by Administrator on 2016/12/23 0023.
 */
//引包
var mongoose = require("mongoose");
var db = require("./db.js");
var ObjectId=require("mongodb").ObjectID;
var bookSchema=new mongoose.Schema({
    name:{type:String},
    author:{type:String},
    price:{type:Number}
});
bookSchema.statics.findAll= function (callback) {
    this.model("Book").find({},callback)
}
bookSchema.statics.findByName= function (name, callback) {
    this.model("Book").find({"name":name},callback)
}
bookSchema.statics.findById= function (id, callback) {
    //this.model("Book").find({"_id":ObjectId(id)},callback)
    this.model("Book").find({"_id":id},callback)
}
/*bookSchema.statics.updateByName= function (conditions, update, options, callback) {
    this.model("Student").update(conditions,update,options,callback);
}*/
var bookModel=db.model("Book",bookSchema);

module.exports=bookModel;